import type {
  OrderPre,
  AddressItem,
  OrderDetail,
  Logistics,
} from "@/types/order";
import { request } from "@/utils/request";

/**
 * 查询药品订单预支付信息
 * @param params Object
 * @returns Promise
 */
export const getMedicalOrderPre = (params: { prescriptionId: string }) => {
  return request<OrderPre>("/patient/medicine/order/pre", "GET", params);
};

/**
 * 获取收货地址列表
 * @returns Promise
 */
export const getAddressList = () => {
  return request<AddressItem[]>("/patient/order/address");
};

/**
 * 创建药品订单
 * @param data Object
 * @returns Promise
 */
export const createMedicalOrder = (data: {
  id: string;
  addressId: string;
  couponId?: string;
}) => request<{ id: string }>("/patient/medicine/order", "POST", data);

/**
 * 获取药品订单详情
 * @param id string
 * @returns Promise
 */
export const getMedicalOrderDetail = (id: string) => {
  return request<OrderDetail>(`/patient/medicine/order/detail/${id}`);
};

/**
 * 获取药品订单物流信息
 * @param id string
 * @returns Promise
 */
export const getMedicalOrderLogistics = (id: string) => {
  return request<Logistics>(`/patient/order/${id}/logistics`);
};
